import { reactive, readonly } from 'vue'

// State
const state = reactive({
  isRunning: false,
  currentQuestion: null,
  logs: []
})

// Actions
function startSolving() {
  state.isRunning = true
}

function stopSolving() {
  state.isRunning = false
}

function updateCurrentQuestion(question) {
  state.currentQuestion = question
}

function addLog(message) {
  state.logs.unshift(message)
  
  // Keep logs limited to 50 entries
  if (state.logs.length > 50) {
    state.logs.pop()
  }
}

function clearLogs() {
  state.logs = []
}

// Store
export function useQuizStore() {
  return {
    state: readonly(state),
    startSolving,
    stopSolving,
    updateCurrentQuestion,
    addLog,
    clearLogs
  }
} 